package com.rabbitmq.demo.service.impl;

import com.rabbitmq.demo.dao.OrderDao;
import com.rabbitmq.demo.pojo.Order;
import com.rabbitmq.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderDao orderDao;
    @Override
    public Order save(Order order) {
        order = orderDao.save(order);
        return order;
    }

    @Override
    public Order getById(Long id) {
        return orderDao.getOne(id);
    }

    @Override
    public void update(Order order) {
        orderDao.save(order);
    }

    @Override
    public List<Order> getListByUserIdAndStateOrderByIdDesc(Long userId, int state) {
        return orderDao.getListByUserIdAndStateOrderByIdDesc(userId,state);
    }
}
